#include <stdio.h>
#include "mpi.h"
#include "dtypes.h" /* include for tests */

#define COUNT 5

int main(int argc, char **argv)
{
    int i, blocklengths[COUNT];
    MPI_Aint displacements[COUNT];
    MPI_Datatype newtype;

    int size;
    MPI_Aint ext, ub, lb;

    MPI_Init(&argc, &argv);
    
    /**********************************
     * direct test of MPI_Type_hindexed *
     *********************************/
    for (i = 0; i < COUNT; i++)
    {
        blocklengths[i] = 2;
        displacements[i] = i*10;
    }

    MPI_Type_hindexed(COUNT, blocklengths, displacements,
            MPI_INT, &newtype);

    TEST_print_type(newtype);

    /* additional tests */
    MPI_Type_size(newtype, &size);
    MPI_Type_extent(newtype, &ext);
    MPI_Type_lb(newtype, &lb);
    MPI_Type_ub(newtype, &ub);

    fputs("Results:\n", stderr);

    fprintf(stderr, "size: %d, extent: %d\nlb: %d, ub: %d\n", 
            size, ext, lb, ub);

    MPI_Finalize();

    return(0);
}

